package model

// SkillEffect 技能效果子类
type SkillEffectType int

const (
	EffectDamage            SkillEffectType = iota + 1 // 伤害
	EffectAddDefense                                   // 增加防御
	EffectDizzy                                        // 眩晕效果
	EffectReduceMagicResist                            // 魔法抗性降低
	EffectAddDodge                                     // 增加闪避
	EffectDefenseBeIgnored                             // 无视防御
	EffectSlowDown                                     // 被减速
	EffectShield                                       // 护盾
	EffectReducePhysical                               // 减少物理伤害
	EffectReboundDamage                                // 反弹伤害
	EffectAddAtk                                       // 增加攻击力
	EffectFreeze                                       // 冻结效果
	EffectRidicule                                     // 嘲讽
	EffectTreat                                        // 治疗
	EffectMaxHpTreat                                   // 最大生命恢复
)

// 是否是增益buff
func IsBuffEffect(effect SkillEffectType) bool {
	if effect == EffectAddDefense || effect == EffectShield || effect == EffectReducePhysical ||
		effect == EffectReboundDamage || effect == EffectAddAtk || effect == EffectMaxHpTreat {
		return true
	}
	return false
}

// 技能效果释放类
type EffectExecutor interface {
	Execute(target *FightHero) // 效果施加
}

// 眩晕效果
type DizzyEffectExecutor struct {
	Effect
}

func (e DizzyEffectExecutor) Execute(target *FightHero) {
	// 什么都不做，放个DeBuff就行
}

func NewDizzyExecutor() DizzyEffectExecutor {
	return DizzyEffectExecutor{}
}

type EffectFactory struct{}

func NewEffectFactory() EffectFactory {
	return EffectFactory{}
}

func (f *EffectFactory) CreateEffectExecutor(target *FightHero, effect Effect) (EffectExecutor, error) {
	effectType := effect.Type
	switch effectType {
	case EffectDizzy:
		return NewDizzyExecutor(), nil
	default:
		panic("unhandled default case")

	}
	return nil, nil
}
